import * as types from './mutation-type'
import mixins from '../mixin'

const mutations = {
    [types.SET_TOKEN](state, token) {
        localStorage.token = token; //缓存到本地
        state.token = token
    },
    [types.SET_MENU](state, index) {
        localStorage.menuActive = index;
        state.menuActive = index;
    },
    [types.UPDATE_SEARCH_TEXT](state, text) {
        state.searchText = text;
    },
    [types.SET_USER](state, user) {
        state.user = user;
    },
    [types.SET_INDEX_TYPE](state, data) {
        state.indexTypes = data;
        state.brandData = mixins.methods.getBrandData(state.indexTypes.da_fenlei_data.filter(item => item.Id), state.indexTypes.xiao_fenlei_data)
    },
    [types.SET_DIALOG](state, flag) {
        state.isSeller = flag;
    },
    [types.SET_QQKF](state, url) {
        state.qqKf = url;
    },
    [types.SET_SUBSTATION](state, data) {
        state.subStation = data;
        document.querySelector('#icon').setAttribute('href', data.fenzhan_ico);
        document.title = data.fenzhan_mingzi
    },

};

export default mutations
